<template>
	<div>
		<!-- 抽屉 -->
		<el-drawer title="" :visible.sync="drawer" :direction="direction" size="80%" :before-close="handleClose">
			<el-row>
				<el-col :span="22" :offset="1">
					<div>
						<template>
							<el-table :data="tableData" stripe style="width: 100%">
								<el-table-column prop="date" label="日期" width="180">
								</el-table-column>
								<el-table-column prop="name" label="姓名" width="180">
								</el-table-column>
								<el-table-column prop="address" label="地址">
								</el-table-column>
								<el-table-column fixed="right" label="操作" width="180">
									<template slot-scope="scope">
										<el-button type="primary" size="mini">添加</el-button>
									</template>
								</el-table-column>
							</el-table>
						</template>
						<template>
							<!--@size-change：当条数发现改变时触发-->
							<!--@current-change：当页码发生改变时触发-->
							<el-pagination style="margin-top: 5px;" layout="sizes, prev, pager, next, jumper, ->, total" :total="total"
							 :page-size.sync="pageSize" :page-sizes="pageSizes" :current-page.sync="currentPage" :pager-count="pagerCount"
							 background @size-change="handleSizeChange" @current-change="handleCurrentChange">
							</el-pagination>
						</template>
					</div>
				</el-col>
			</el-row>
		</el-drawer>
		<!-- 模态框 -->
		<el-dialog :visible.sync="dialogVisible" top="25px" width="70%">
			<div style="box-shadow: 0 10px 10px rgba(132, 172, 232, .12), 0 0 6px rgba(132, 172, 232, .04)">
				<div align="center">
					<h2>物料组成设计单</h2>
				</div>
				<div>
					<el-form ref="form" id="form">
						<el-row>
							<el-col :span="10" :offset="1">
								<el-form-item label="设计单编号：" label-width="110px">
									<span>{{designSheetNo}}</span>
								</el-form-item>
							</el-col>
							<el-col :span="10" :offset="2">
								<el-form-item label="设计人：" label-width="95px">
									<el-input v-model="designer"></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="10" :offset="1">
								<el-form-item label="产品名称：" label-width="110px">
									<span>{{productName }}</span>
								</el-form-item>
							</el-col>
							<el-col :span="10" :offset="2">
								<el-form-item label="产品编号：" label-width="110px">
									<span>{{identificationOfProduct}}</span>
								</el-form-item>
							</el-col>
							<el-col :span="22" :offset="1">
								<template>
									<el-table :data="materials" stripe style="width: 100%">
										<el-table-column prop="date" label="日期" width="180">
										</el-table-column>
										<el-table-column prop="name" label="姓名" width="180">
										</el-table-column>
										<el-table-column prop="address" label="地址">
										</el-table-column>
									</el-table>
								</template>
							</el-col>
						</el-row>
						<el-row>
							<el-col :span="22" :offset="1">
								<el-form-item label="物料总成本：" label-width="110px">
									<span>{{totalMaterialCost}}</span>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row>
							<el-col :span="10" :offset="1">
								<el-form-item label="变更人：" label-width="110px">
									<el-input v-model="changeAPerson"></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="10" :offset="2">
								<el-form-item label="变更时间:" label-width="110px">
									<span>{{changeTime}}</span>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row>
							<el-col :span="22" :offset="1">
								<el-form-item label="设计要求:" label-width="110px">
									<el-input resize="none" type="textarea" :rows="4" v-model="designRequirements" autocomplete="off"></el-input>
								</el-form-item>
							</el-col>
						</el-row>
					</el-form>
				</div>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="drawer = true">添加新物料</el-button>
				<el-button type="primary">重新提交</el-button>
			</span>
		</el-dialog>
		<!-- 主题 -->
		<el-container>
			<el-header>
				<el-row>
					<el-col :span="24">
						<div class="reCheckProductSumClass">
							当前可变更的设计单总数：{{reCheckProductSum}}例
						</div>
					</el-col>
				</el-row>
			</el-header>
			<el-main style="height: 475px; overflow: hidden; background: white; border:1px solid white ; border-radius: 8px;">
				<div>
					<template>
						<el-table :data="tableData" stripe style="width: 100%">
							<el-table-column prop="date" label="日期" width="180">
							</el-table-column>
							<el-table-column prop="name" label="姓名" width="180">
							</el-table-column>
							<el-table-column prop="address" label="地址">
							</el-table-column>
							<el-table-column fixed="right" label="操作" width="180">
								<template slot-scope="scope">
									<el-button type="primary" size="mini" @click="dialogVisible=true">变更</el-button>
								</template>
							</el-table-column>
						</el-table>
					</template>
					<template>
						<!--@size-change：当条数发现改变时触发-->
						<!--@current-change：当页码发生改变时触发-->
						<el-pagination style="margin-top: 5px;" layout="sizes, prev, pager, next, jumper, ->, total" :total="total"
						 :page-size.sync="pageSize" :page-sizes="pageSizes" :current-page.sync="currentPage" :pager-count="pagerCount"
						 background @size-change="handleSizeChange" @current-change="handleCurrentChange">
						</el-pagination>
					</template>
				</div>
			</el-main>
		</el-container>
	</div>
</template>

<script>
	export default {
		name: 'makeTheMaterialCompositionDesignList',
		data() {
			return {
				/* 当前时间 */
				nowTime: '',
				/* 总条数 */
				reCheckProductSum: 4,
				/* table数据 */
				tableData: [{
					date: '2016-05-02',
					name: '王小虎',
					address: '上海市普陀区金沙江路 1518 弄'
				}, {
					date: '2016-05-04',
					name: '王小虎',
					address: '上海市普陀区金沙江路 1517 弄'
				}, {
					date: '2016-05-01',
					name: '王小虎',
					address: '上海市普陀区金沙江路 1519 弄'
				}, {
					date: '2016-05-03',
					name: '王小虎',
					address: '上海市普陀区金沙江路 1516 弄'
				}],
				/* 分页 */
				total: 500, //总条数
				pageSize: 5, //每页显示多少条
				pageSizes: [2, 3, 5, 7], //每页显示条数候选值
				currentPage: 1, //当前页
				pagerCount: 5, //最多显示的页码，多余的会折叠
				/* 模态框显示 */
				dialogVisible: false,
				/* 选择的物料 */
				materials: [],
				/* 抽屉 */
				drawer: false,
				direction: 'ltr',
				/* 设计单编号 */
				designSheetNo:'',
				/* 设计人 */
				designer:'',
				/* 产品名称 */
				productName:'',
				/* 产品编号 */
				identificationOfProduct:'',
				/* 物料总成本 */
				totalMaterialCost:'',
				/* 变更人 */
				changeAPerson:'',
				/* 变更时间 */
				changeTime:'',
				/* 设计要求 */
				designRequirements:'',
			}
		},
		mounted: function() {
			/* 页面加载时启动计时器 */
			this.currentTime();
			/* 查询所有的一级分类 */

		},
		methods: {
			/* 制定设计单 */
			developDesignSheet() {
				
			},

			/* 改变size[每页条数]调用方法*/
			handleSizeChange(size) {
				/* 只要改变马上调用分页查询 */
			},

			/* 改变page[当前页码]调用方法*/
			handleCurrentChange(page) {
				/* 只要改变马上调用分页查询 */
			},

			/* 定时器 */
			currentTime() { //定时器
				setInterval(this.getDate, 100)
			},

			/* 获取当前时间 */
			getDate() {
				const year = new Date().getFullYear()
				const month = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : (new Date().getMonth() + 1)
				const date = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate()
				const hh = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours()
				const mm = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
				const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
				const week = new Date().getDay()
				this.nowTime = year + '年' + month + '月' + date + '日' + ' ' + hh + ':' + mm + ':' + ss
			}
		},
		// 销毁定时器
		beforeDestroy: function() {
			if (this.getDate) {
				clearInterval(this.getDate) // 在Vue实例销毁前，清除时间定时器
			}
		},
	}
</script>

<style scoped>
	#form .el-form-item {
		background-color: aliceblue;
	}

	/* 页面地址栏显示的背景设置 */
	.bg-9EA4D8 {
		color: #FFFFFF;
		background-color: #A4D1FF;
	}

	.el-header {
		line-height: 40px;
		background-color: #333333;
	}
	
	.reCheckProductSumClass {
		font-size: 13px;
	}

	.el-dialog__body {
		padding: 0;
	}

	.el-input__inner {
		color: #0000FF;
	}
</style>
